using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ChinaDynastyTours.Controls;

namespace ChinaDynastyTours.Views
{
    public partial class GuideStatusLookupTourgroup : DevExpress.XtraEditors.XtraForm
    {
        private DataRow[] _drs;

        public GuideStatusLookupTourgroup(DataRow[] drs)
        {
            InitializeComponent();

            _drs = drs;
        }

        private void GuideStatusLookupTourgroup_Load(object sender, EventArgs e)
        {
            string[] tourgroupIds = new string[_drs.Length];
            for (int i = 0; i < _drs.Length; i++)
                tourgroupIds[i] = _drs[i]["TourgroupID"].ToString();

            teamGridControl.DataSource = TeamGroupCtrl.GetTeamGroupData(tourgroupIds);
        }

        private void teamGridView_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
        {
            if (e.Clicks == 2)
            {
                Cursor.Current = Cursors.WaitCursor;

                DataTable dt = teamGridControl.DataSource as DataTable;
                dt.DefaultView.RowFilter = string.Format("TourgroupID='{0}'", teamGridView.GetRowCellValue(e.RowHandle, "TourgroupID"));
                new TourGroupScheduleForm(dt.DefaultView).ShowDialog(this);
                dt.DefaultView.RowFilter = "";

                Cursor.Current = Cursors.Default;
            }
        }
    }
}